/**
 * 5点里选3点，组成最大的三角形
 * point：坐标法计算三角形面积。穷举三角形组合。
 * @param
 * @Date ：created in 2022/3/8 18:44
 * @return
 */
public class LargestTriangleArea {
    public static void main(String args[]){
        int[][] points = {{0,0},{0,1},{1,0},{0,2},{2,0}};
    }
    public double largestTriangleArea(int[][] points) {
        double ans=0;
        for (int i = 0; i < points.length; i++) {
            for (int j = i+1; j <points.length ; j++) {
                for (int k = j+1; k < points.length; k++) {
                    ans=Math.max(ans,area(points[i],points[j],points[k]));
                }
            }
        }
        return ans;
    }

    public double area(int[] a,int[] b,int[] c){
        return 0.5* Math.abs(a[0]*b[1]+b[0]*c[1]+c[0]*a[1]-a[0]*c[1]-b[0]*a[1]-c[0]*b[1]);
    }
}
